using System;
using System.Data;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace Microsoft.EntityFrameworkCore.Dm.Storage.Internal;

public class DmTimeSpanTypeMapping : TimeSpanTypeMapping
{
	public DmTimeSpanTypeMapping([NotNull] string storeType, DbType? dbType = null)
		: base(storeType, dbType)
	{
	}

	protected DmTimeSpanTypeMapping(RelationalTypeMappingParameters parameters)
		: base(parameters)
	{
	}//IL_0001: Unknown result type (might be due to invalid IL or missing references)


	public override RelationalTypeMapping Clone(string storeType, int? size)
	{
		return new DmTimeSpanTypeMapping(this.Parameters.WithStoreTypeAndSize(storeType, size, null));
	}

	// Token: 0x060001DF RID: 479 RVA: 0x000097E8 File Offset: 0x000079E8
	public override CoreTypeMapping Clone(ValueConverter converter)
	{
		return new DmTimeSpanTypeMapping(this.Parameters.WithComposedConverter(converter));
	}

	// Token: 0x060001E0 RID: 480 RVA: 0x0000980C File Offset: 0x00007A0C
	protected override string GenerateNonNullSqlLiteral(object value)
	{
		TimeSpan timeSpan = (TimeSpan)value;
		string text = timeSpan.Milliseconds.ToString();
		text = text.PadLeft(4 - text.Length, '0');
		DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(0x1D, 5);
		defaultInterpolatedStringHandler.AppendLiteral("INTERVAL '");
		defaultInterpolatedStringHandler.AppendFormatted<int>(timeSpan.Days);
		defaultInterpolatedStringHandler.AppendLiteral(" ");
		defaultInterpolatedStringHandler.AppendFormatted<int>(timeSpan.Hours);
		defaultInterpolatedStringHandler.AppendLiteral(":");
		defaultInterpolatedStringHandler.AppendFormatted<int>(timeSpan.Minutes);
		defaultInterpolatedStringHandler.AppendLiteral(":");
		defaultInterpolatedStringHandler.AppendFormatted<int>(timeSpan.Seconds);
		defaultInterpolatedStringHandler.AppendLiteral(".");
		defaultInterpolatedStringHandler.AppendFormatted(text);
		defaultInterpolatedStringHandler.AppendLiteral("' DAY TO SECOND");
		return defaultInterpolatedStringHandler.ToStringAndClear();
	}
}
